<template>
	<view>
		<u-tabbar
			:value="value2"
			:placeholder="false"
			:fixed="true"
			activeColor="#e85a71"
			:safeAreaInsetBottom="true" >
			
			<u-tabbar-item :text="i18n=='cn'?'首页':'Home'" @click='click(0)' >
				<image
					class="timg"
					slot="inactive-icon"
					src="../../static/images/home.png"
				></image>
				<image
					class="timg"
					slot="active-icon"
					src="../../static/images/home_highlighted.png"
				></image>
			</u-tabbar-item>
			<u-tabbar-item :text="i18n=='cn'?'应用':'App'" @click='click(1)' >
				<image
					class="timg"
					slot="inactive-icon"
					src="../../static/images/apps.png"
				></image>
				<image
					class="timg"
					slot="active-icon"
					src="../../static/images/apps_highlighted.png"
				></image>
			</u-tabbar-item>
			<u-tabbar-item v-if="clientType!=='pda'" :text="i18n=='cn'?'开单':'Billing'" @click='click(2)'>
				<image
					class="timg"
					slot="inactive-icon"
					src="../../static/images/order.png"
				></image>
				<image
					class="timg"
					slot="active-icon"
					src="../../static/images/order_highlighted.png"
				></image>
			</u-tabbar-item>
			<u-tabbar-item v-if="clientType!=='pda'" :text="i18n=='cn'?'报表':'Report'" @click='click(3)'>
				<image
					class="timg"
					slot="inactive-icon"
					src="../../static/images/purchase.png"
				></image>
				<image
					class="timg"
					slot="active-icon"
					src="../../static/images/purchase_highlighted.png"
				></image>
			</u-tabbar-item>
			<u-tabbar-item :text="i18n=='cn'?'我的':'Mine'" @click='click(4)'>
				<image
					class="timg"
					slot="inactive-icon"
					src="../../static/images/mine.png"
				></image>
				<image
					class="timg"
					slot="active-icon"
					src="../../static/images/mine_highlighted.png"
				></image>
			</u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
export default {
	props: {
		value2: {
			type:Number,
			default:0
		},
	},
	
	data(){
		return{
			i18n:'cn',
			clientType:''
			
		}
	},
		
	mounted:function(){
		this.i18n = uni.getStorageSync('i18n')==''?'cn':uni.getStorageSync('i18n')
		this.clientType = uni.getStorageSync('clientType')
	},
	// computed:{
	// 	value2(){
	// 		return this.$store.state.tabBarIndex
	// 	}
	// },
	methods:{
		change(name) {
		
			this.value2 = name
		},
		click(index){
			console.log(index)
			var preindex = this.$store.state.tabBarIndex
			if(index == preindex) return
			this.$store.commit('changeTabBarIndex',index)
			if(index == 0){
				var indexTempletName = uni.getStorageSync('indexTempletName')
				if(indexTempletName == 'appsj_index' || indexTempletName=='appsj_index_pda'){
					uni.switchTab({
						url:'../index/index'
					})
				}else if(indexTempletName == 'appsj_list'){
					var pageName2 = uni.getStorageSync('pageName')
					var templetName2 = uni.getStorageSync('templetName',)
					var modid = uni.getStorageSync('modid')
					var menuid = uni.getStorageSync('menuid')
					if(templetName2 == 'appsj_index'){
						uni.switchTab({
							url:'../index/index'
						})
					}else if(templetName2 == 'appsj_list'){
						uni.reLaunch({
							url:'../infolist/infolist?templatename='+templetName2+'&pagename='+pageName2+'&menuid='+menuid+'&menuname=首页&modid='+modid
						})
					}
				}
				
			}else if(index == 1){
				uni.switchTab({
					url:'/pages/app/app'
				})
			}else if(index == 2){
				uni.switchTab({
					url:'/pages/createorder/createorder'
				})
			}else if(index == 3){
				uni.switchTab({
					url:'/pages/report/report'
				})
			}else if(index == 4){
				uni.switchTab({
					url:'/pages/me/me'
				})
			}
		},
	},
}
</script>

<style>
	.timg{width: 20px;height: 20px;}
</style>